package cn.yunhe.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.yunhe.biz.IMajorsBiz;
import cn.yunhe.biz.MajorsBizImpl;
import cn.yunhe.entity.Majors;

@WebServlet("/MajorsListServlet")
public class MajorsListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		
		IMajorsBiz majorsBiz = new MajorsBizImpl();
		List<Majors> list = majorsBiz.getAllMajorsByRate();
		HttpSession session = request.getSession();
		if (list !=null) {
			session.setAttribute("list", list);
			request.getRequestDispatcher("majorsList.jsp").forward(request, response);
		} else {
			response.sendRedirect("ProvienceMessage.jsp");
		}
		
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doGet(request, response);
	}

}
